<!-- Modal -->
<div class="modal fade " id="addCustCertModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">证件信息维护</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">客户姓名</label>
                        <div class="col-sm-7">
                            <select id="addCustCertModel_custId" style="width: 150px"  class="form-control select2"  >
                            </select>
                            <input id="addCustCertModel_id" type="hidden">
                        </div>
                    </div>

                    <div class="form-group" id="weightDiv">
                        <label for="inputEmail3" class="col-sm-2 control-label">证件类型</label>
                        <div class="col-sm-7">
                            <select id="addCustCertModel_certType" style="width: 150px"  class="form-control select2"  >
                            </select>
                        </div>
                    </div>
                    <div class="form-group" id="weightDiv">
                        <label for="inputEmail3" class="col-sm-2 control-label">证件号码</label>
                        <div class="col-sm-7">
                            <input id="addCustCertModel_certCode" type="text" class="form-control" style="width: 100%;" >
                        </div>
                    </div>

                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button id="btnSubmit" type="button" class="btn btn-primary pull-right"
                            onclick="addCustCertModel_save()">保存
                    </button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>
<script>
    function addCustCertModel_init() {

        $("#addCustCertModel_id").val("");
        $("#addCustCertModel_custId").empty();
        $("#addCustCertModel_certType").empty();
        $("#addCustCertModel_certCode").val("");
    }
    function addCustCertModel_setValue(index) {
        var url1 = "/custcert/select/cust" ;
        var url2 = "/custcert/select/certtype" ;
        if(index === -1) {
            setFormValue(url1,"addCustCertModel_custId") ;
            setFormValue(url2,"addCustCertModel_certType") ;
        } else {
            var options = $("#table1").bootstrapTable("getData");
            var row = options[index];
            $("#addCustCertModel_id").val(row.id);
            $("#addCustCertModel_certCode").val(row.certCode);

            setFormValue(url1,"addCustCertModel_custId",row.custId) ;
            setFormValue(url2,"addCustCertModel_certType",row.certType) ;
        }
    }


    function addCustCertModel_save() {
        var data = {
            id: val("addCustCertModel_id"),
            custId: val("addCustCertModel_custId","select"),
            certType:val( "addCustCertModel_certType","select"),
            certCode: val("addCustCertModel_certCode")
        };
        var url = "/custcert/save";
        postReq(url, data, function (result) {
            if (result.success) {
                toastr['success']('操作成功', '提示');
                $("#table1").bootstrapTable("refresh");
                $("#addCustCertModel").modal("hide");
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>
